import Vue from 'vue'
import VueRouter from 'vue-router'
import Recommend from "../views/recommend"
import Singers from "../views/singers"
import Rank from "../views/rank"
import Search from "../views/search"
import Router from "vue-router"
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/recommend',
    component: Recommend,
  },
  {
    path: '/recommend',
    name: 'recommend',
    component: Recommend,
    children:[
      {
        path:"recommend_detail/:playlist_id",
        name:"recommend_detail",
        component:()=>import("../components/recommend-detail")
      }
    ]
  },
  {
    path: '/singers',
    name: 'singers',
    component: Singers,
    children:[
      {
        path:"singer_detail/:singer_id",
        name:"singer_detail",
        component:()=>import("../components/recommend-detail")
      }
    ]
  },
  {
    path: '/rank',
    name: 'rank',
    component: Rank
  },
  {
    path: '/search',
    name: 'search',
    component: Search
  },
]
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this,location).catch(err =>err)
}


const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

export default router
